#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>
void Swap(char* p)
{
	char* start = p;
	while (*p)
	{
		*p = *(p + 1);
		p++;
	}
}
int main()
{
	char a[100], b[100];
	gets(a);
	gets(b);
	int len1 = strlen(a);
	int len2 = strlen(b);
	int i = 0, j = 0;
	for (i = 0; i < len1; i++)
	{
		if (a[i] == ' ')
			continue;
		for (j = 0; j < len2; j++)
		{
			if (a[i] == b[j])
				Swap(&a[i]);
		}
	}
	printf("%s", a);

	return 0;
}